package com.renchunlin.permission;

import android.Manifest;
import android.os.Bundle;
import android.widget.Toast;

import com.renchunlin.permission.base.BaseActivity;

public class MainActivity extends BaseActivity {

    /*相机和储存权限*/
    private String[] mStrPermission =
            {Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        getPermission();
    }

    /*授予权限*/
    private void getPermission() {
        requestPermission(mStrPermission, 2);
    }

    /* 权限成功回调函数*/
    @Override
    public void permissinSucceed(int code) {
        super.permissinSucceed(code);
        switch (code) {
            case 2:
                //打开自定义相机拍照
                Toast.makeText(this, "打开相机了!", Toast.LENGTH_SHORT).show();
                break;
        }
    }

    /* 权限失败回调函数*/
    @Override
    public void permissionFailing(int code) {
        super.permissionFailing(code);
    }
}
